#include <stdio.h>
#include <stdlib.h>
#define P(A,q) while(q>=0) fprintf(stderr,"%d", abs((A>>q--)%2));fprintf(stderr,"\n");q=31

int
getbit(int x, int pos)
{
	return (x >> pos) & 1;
}


void
setbit (int* n, int pos, int bit)
{
	if (bit == 1)
		*n |= 1<<pos;
	else
		*n &= ~(1<<pos);
}


int
main()
{
	int in = 0, out;
	int i = 30;
	register int q = 31;
	freopen("bits.in", "r", stdin);
	freopen("bits.out", "w", stdout);
	scanf("%d", &in);

	out = in;
	P(out,q);
	for (i = 30; i >= 1; --i) {
		if (getbit(in, i+1) + getbit(in, i-1) % 2 == 1)
			setbit(&out, i, 1);
		else
			setbit(&out, i, 0);
		P(out,q);
	}
	printf("%d\n", out);
	return 0;
}
